/*
 * @Title JNI.java
 * @Description 1.javac -encoding UTF-8 JNI.java生成*.class文件
 * 2.javah -jni *生成*.h文件
 * 3.cpp实现JNI.java文件native方法生成*.cpp，*.cpp、*.java、${JAVA_HOME}/include/win32/jni.h和${JAVA_HOME}/include/win32/jni_md.h生成*.dll文件
 * 4.*.dll加入到环境变量
 * @Copyright Copyright(c) 2018
 * @Company com.lizhen
 * @author lizhen
 * @version 0.0.1
 */
package com.lizhen.core.function.jni;

/**
 * @author lizhen
 */
public class JNI {

    private static final String DLL_PATH = "H:\\Source\\gitee\\BackEnd\\Java\\1.8\\api\\main\\resource\\com\\lizhen\\core\\function\\jni\\HelloJNI.dll";
    private static final String DLL_DIR_PATH = "H:\\Source\\gitee\\BackEnd\\Java\\1.8\\api\\main\\resource\\com\\lizhen\\core\\function\\jni";

    public static void main(String[] args) {
        System.load(DLL_PATH);
/*        System.setProperty("java.library.path", System.getProperty("java.library.path") + ";" + DLL_DIR_PATH);
        try {
            Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
            fieldSysPath.setAccessible(true);
            fieldSysPath.set(null, null);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        System.loadLibrary("HelloJNI");*/
        JNI jni = new JNI();
        jni.helloJNI();
    }

    public native void helloJNI();
}
